<?php
/*
# ------------------------------------------------------------------------
# JA Job Board Package
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
# Author: JoomlArt.com
# Websites: http://www.joomlart.com - http://www.joomlancers.com.
# ------------------------------------------------------------------------
*/
jimport( 'joomla.application.component.view' );

class JAJobBoardViewJASalary extends JAView
{
    /**
     * Display the view
     */
    function display($tmpl = null)
    {
		$task = JRequest::getVar("task", '');
		switch ($task){
			case 'add':
			case 'edit':				
				JAJobBoardViewJASalary::displayForm();
				break;			
			default:
				JAJobBoardViewJASalary::displayListItems();
		}
		
		parent::display($tmpl);
  	}
  	
  	
  	/**
  	* Display List of items
  	*/
  	function displayListItems($tpl=null){  		
  		global $mainframe, $option;
        $option_1 = $option.'.jasalary';
		$search	= $mainframe->getUserStateFromRequest( "$option_1.search", 'search', 	'',	'string' );
		$lists['search']	= JString::strtolower($search );
		$lists['order']		= $mainframe->getUserStateFromRequest( $option_1.'.filter_order',		'filter_order',		's.ordering',	'cmd' );
		$lists['order_Dir']	= $mainframe->getUserStateFromRequest( $option_1.'.filter_order_Dir',	'filter_order_Dir',	'',				'word' );
		$lists['option']	= $option;
		$filter_state		= $mainframe->getUserStateFromRequest( $option_1.'.filter_state', 'filter_state', '',	'word' );
		// state filter
		$lists['state']	= JHTML::_('grid.state',  $filter_state );
		
        // get data items
        $items = &$this->get('Items');        

        $pagination = &$this->get('Pagination');
        
        $this->assignRef('lists', $lists);
        $this->assignRef('items', $items);
        $this->assignRef('pagination', $pagination);
        
  	}
  	/**
  	* Display edit form
  	*/
  	function displayForm(){  	    
  		global $option;
  		
  	    $item = &$this->get('Item');  	
  	   	
		if ( !$item->id) {
			$item->published = 1;
		}
		
		$published = JHTML::_('select.booleanlist', 'published', '', $item->published);
		
		if($item->id){
        $query = 'SELECT ordering as value, value as text '
                .' FROM #__ja_salary  '
                .' ORDER BY ordering';
            $order = JHTML::_('list.genericordering',  $query );
            $ordering = JHTML::_('select.genericlist',   $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $item->ordering ) );
        } else {
            $ordering = '<input type="hidden" name="ordering" value="'. $item->ordering .'" />'. JText::_( 'DESCNEWITEMSLAST' );
        }


  	    $this->assignRef('ordering', $ordering);
  	    $this->assignRef('option', $option);
  	    $this->assignRef('published', $published);
  	    $this->assignRef('item', $item);
	}
}
?>